#include <QListWidgetItem>
#include "gameinfo.h"
#include "ui_gameinfo.h"
#include "ipsonitem.h"
#include "qDebug"

GameInfo::GameInfo(QWidget *parent) :
    QFrame(parent),
    ui(new Ui::GameInfo)
{
    ui->setupUi(this);
}
GameInfo::GameInfo(DataModel *model,QList<DataSubIp *> *list,QWidget *parent) :
    QFrame(parent),ui(new Ui::GameInfo)
{
    ui->setupUi(this);
    this->model = model;
    this->ipsList = list;
    ui->le_id->setText(QString::number(model->id));
    ui->le_gameName->setText(model->gameName);
    ui->le_buildVer->setText(QString::number(model->buildVer));
    ui->le_gameVer->setText(model->gameVer);
    ui->le_useSpace->setText(QString::number(model->userSpace));
    ui->le_gameICO->setText(model->gameICO);
    ui->le_runPath->setText(model->runPath);
    ui->le_downUrl->setText(model->downUrl);
    ui->le_gameDir->setText(model->gameDir);
    ui->le_created_at->setText(model->createdAt);
    ui->le_updated_at->setText(model->updatedAt);
    ui->le_size->setText(QString::number(model->size));
    ui->le_initSize->setText(QString::number(model->needSize));
    for(int i = 0;i<ipsList->size();i++){
        //ipsList->at(i)->setupUi();
        QSize s ;
        s.setHeight(27);
        IpSonItem *itemW = new IpSonItem(ipsList->at(i),model);
        QListWidgetItem *item=new QListWidgetItem;
        item->setSizeHint(s);
        ui->listWidget_ips->addItem(item);
        ui->listWidget_ips->setItemWidget(item,itemW);
    }


}

void GameInfo::setupUi(){


}

GameInfo::~GameInfo()
{
    delete ui;
    qDebug()<<"gameInfo";
}
